// function getconfig(){
// 	return  {
// 		xmppURL: '//im-api-v2.easemob.com/ws',    // xmpp Server地址
// 		apiURL: '//a1.easemob.com',               // rest Server地址https://a1.easemob.com
// 		appkey: '1113200507065018#test',        // App key
// 		https : false,                             // 是否使用https
// 		isHttpDNS: true,                          // 3.0 SDK支持，防止DNS劫持从服务端获取XMPPUrl、restUrl 
// 		isMultiLoginSessions: false,              // 是否开启多页面同步收消息，注意，需要先联系商务开通此功能
// 		isDebug: true,                           // 打开调试，会自动打印log，在控制台的console中查看log
// 		autoReconnectNumMax: 2,                   // 断线重连最大次数
// 		heartBeatWait: 4500,                      // 使用webrtc（视频聊天）时发送心跳包的时间间隔，单位ms
// 		delivery: true,                           // 是否发送已读回执
// 	};
// }
// function getemoji(){
// 	return  {
// 		path: "../img/faces/",
// 		map: {
// 			"[):]": "ee_1.png",
// 			"[:D]": "ee_2.png",
// 			"[;)]": "ee_3.png",
// 			"[:-o]": "ee_4.png",
// 			"[:p]": "ee_5.png",
// 			"[(H)]": "ee_6.png",
// 			"[:@]": "ee_7.png",
// 			"[:s]": "ee_8.png",
// 			"[:$]": "ee_9.png",
// 			"[:(]": "ee_10.png",
// 			"[:'(]": "ee_11.png",
// 			"[<o)]": "ee_12.png",
// 			"[(a)]": "ee_13.png",
// 			"[8o|]": "ee_14.png",
// 			"[8-|]": "ee_15.png",
// 			"[+o(]": "ee_16.png",
// 			"[|-)]": "ee_17.png",
// 			"[:|]": "ee_18.png",
// 			"[*-)]": "ee_19.png",
// 			"[:-#]": "ee_20.png",
// 			"[^o)]": "ee_21.png",
// 			"[:-*]": "ee_22.png",
// 			"[8-)]": "ee_23.png",
// 			"[(|)]": "ee_24.png",
// 			"[(u)]": "ee_25.png",
// 			"[(S)]": "ee_26.png",
// 			"[(*)]": "ee_27.png",
// 			"[(#)]": "ee_28.png",
// 			"[(R)]": "ee_29.png",
// 			"[({)]": "ee_30.png",
// 			"[(})]": "ee_31.png",
// 			"[(k)]": "ee_32.png",
// 			"[(F)]": "ee_33.png",
// 			"[(W)]": "ee_34.png",
// 			"[(D)]": "ee_35.png"
// 		}
// 	};
// }
// function parseEmoji(msg){ 
// 	console.log('啧啧啧')
// 	if(typeof getemoji() === "undefined" || typeof getemoji().map === "undefined"){
// 		return msg;
// 	}
// 	var emoji = getemoji(),
// 		reg = null;
// 	var msgList = [];
// 	var objList = [];
// 	for(var face in emoji.map){
// 		if(emoji.map.hasOwnProperty(face)){
// 			while(msg.indexOf(face) > -1){
// 				msg = msg.replace(face, "^" + emoji.map[face] + "^");
// 			}
// 		}
// 	}
// 	var ary = msg.split("^");
// 	console.log(ary)
// 	var reg = /^e.*g$/;
// 	for(var i = 0; i < ary.length; i++){
// 		if(ary[i] != ""){
// 			msgList.push(ary[i]);
// 		}
// 	}
// 	for(var i = 0; i < msgList.length; i++){
// 		if(reg.test(msgList[i])){
// 			var obj = {};
// 			obj.data = msgList[i];
// 			obj.type = "emoji";
// 			objList.push(obj);
// 		}
// 		else{
// 			var obj = {};
// 			obj.data = msgList[i];
// 			obj.type = "txt";
// 			objList.push(obj);
// 		}
// 	}
// 	return objList;
// }

function getUrl(){
    var apiUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//a1.easemob.com"
    var xmppUrl = "//im-api-v2.easemob.com/ws"
    if(window.location.href.indexOf("www.test.com") !== -1 ){
        apiUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//a1.easemob.com"
        xmppUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//im-api-v2.easemob.com/ws"
    }
    else if(window.location.href.indexOf("172.17.1.95") !== -1){
        apiUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//a1.easemob.com"
        xmppUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//im-api-v2.easemob.com/ws"
    }
    else if(window.location.href.indexOf("localhost") !== -1){
        apiUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//a1.easemob.com"
        xmppUrl = (window.location.protocol === "https:" ? "https:" : "http:") + "//im-api-v2.easemob.com/ws"
    }
    return {
        apiUrl: apiUrl,
        xmppUrl: xmppUrl
    }
}

function getconfig(){
	return {
		xmppURL: getUrl().xmppUrl,
		apiURL: getUrl().apiUrl,
		appkey: "1113200507065018#test",
		Host: "easemob.com",
		https: true,
		isHttpDNS: false,
		isMultiLoginSessions: true,
		isWindowSDK: false,
		isSandBox: false,
		isDebug: true,
		isStropheLog: false,
		autoReconnectNumMax: 5,
		autoReconnectInterval: 2,
		isWebRTC: true,//window.RTCPeerConnection && /^https\:$/.test(window.location.protocol),
		i18n: "us",
		isAutoLogin: true,
		p2pMessageCacheSize: 500,
		delivery: true,
		groupMessageCacheSize: 200,
		loglevel: "ERROR",
		enableLocalStorage: true
	}
}

function getemoji(){
	return  {
		path: "/statics/wxdemo/img/faces/",
		map: {
			"[):]": "ee_1.png",
			"[:D]": "ee_2.png",
			"[;)]": "ee_3.png",
			"[:-o]": "ee_4.png",
			"[:p]": "ee_5.png",
			"[(H)]": "ee_6.png",
			"[:@]": "ee_7.png",
			"[:s]": "ee_8.png",
			"[:$]": "ee_9.png",
			"[:(]": "ee_10.png",
			"[:'(]": "ee_11.png",
			"[<o)]": "ee_12.png",
			"[(a)]": "ee_13.png",
			"[8o|]": "ee_14.png",
			"[8-|]": "ee_15.png",
			"[+o(]": "ee_16.png",
			"[|-)]": "ee_17.png",
			"[:|]": "ee_18.png",
			"[*-)]": "ee_19.png",
			"[:-#]": "ee_20.png",
			"[^o)]": "ee_21.png",
			"[:-*]": "ee_22.png",
			"[8-)]": "ee_23.png",
			"[(|)]": "ee_24.png",
			"[(u)]": "ee_25.png",
			"[(S)]": "ee_26.png",
			"[(*)]": "ee_27.png",
			"[(#)]": "ee_28.png",
			"[(R)]": "ee_29.png",
			"[({)]": "ee_30.png",
			"[(})]": "ee_31.png",
			"[(k)]": "ee_32.png",
			"[(F)]": "ee_33.png",
			"[(W)]": "ee_34.png",
			"[(D)]": "ee_35.png"
		}
	};
}
function parseEmoji(msg){ 
	console.log('啧啧啧')
	if(typeof getemoji() === "undefined" || typeof getemoji().map === "undefined"){
		return msg;
	}
	var emoji = getemoji(),
		reg = null;
	var msgList = [];
	var objList = [];
	for(var face in emoji.map){
		if(emoji.map.hasOwnProperty(face)){
			while(msg.indexOf(face) > -1){
				msg = msg.replace(face, "^" + emoji.map[face] + "^");
			}
		}
	}
	var ary = msg.split("^");
	console.log(ary)
	var reg = /^e.*g$/;
	for(var i = 0; i < ary.length; i++){
		if(ary[i] != ""){
			msgList.push(ary[i]);
		}
	}
	for(var i = 0; i < msgList.length; i++){
		if(reg.test(msgList[i])){
			var obj = {};
			obj.data = msgList[i];
			obj.type = "emoji";
			objList.push(obj);
		}
		else{
			var obj = {};
			obj.data = msgList[i];
			obj.type = "txt";
			objList.push(obj);
		}
	}
	return objList;
}